#include<iostream>
#include<cstring>
using namespace std;

struct PERSON {
	char name[40];
	char gender[10];
	int age;
};

int main() {
	PERSON aclass[50];
	int n = 0;
	PERSON *p;
	p = aclass;

	//输入
	cin >> p->name;
	cin >> p->gender;
	cin >> p->age;

	while (strcmp(p->name, "0") != 0 && strcmp(p->gender, "0") != 0 && p->age != 0) {
		n++;
		p++;
		cin >> p->name;
		cin >> p->gender;
		cin >> p->age;

	}

	//输出
	p = aclass + n - 1;
	while (p >= aclass) {
		cout << p->name<<" ";
		cout << p->gender<<" ";
		cout << p->age;
		cout<<endl;
		p--;
		
	}
	return 0;


}
